/**
 * @class SvgContainer
 * @extends SvgElement
 */
var SvgContainer = {
    /**
     * @private
     * @method shape
     * @param {String} t Svg element type 
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    shape: function(t, a) {        
        return new SvgElement(t, this.dom, this.canvas).attr(a);
    },
    /**
     * @method rect
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    rect: function(a) {
        return this.shape("rect", a);
    },
    /**
     * @method circle
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    circle: function(a) {
        return this.shape("circle", a);
    },
    /**
     * @method ellipse
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    ellipse: function(a) {
        return this.shape("ellipse", a);
    },
    /**
     * @method line
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    line: function(a) {
        return this.shape("line", a);
    },
    /**
     * @method polyline
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    polyline: function(a) {
        return this.shape("polyline", a);
    },
    /**
     * @method polygon
     * @param {Object} a Svg element attributes
     * @return {SvgElement}
     */
    polygon: function(a) {
        return this.shape("polygon", a);
    },
    /**
     * @method text
     * @param {String} text The value of the text element
     * @param {Object} a Svg element attributes
     * @return {SvgText}
     */
    text: function(text, a) {
        return new SvgText(text, this.dom, this.canvas).attr(a);
    },
    /**
     * @method image
     * @param {String} href The uri of the image
     * @param {Object} a Svg element attributes
     * @return {SvgImage}
     */
    image: function(href, a) {
        return new SvgImage(href, this.dom, this.canvas).attr(a);
    },
    /**
     * @method group
     * @param {Object} a Svg element attributes
     * @return {SvgContainer}
     */
    group: function(a) {
        return new SvgContainer("g", this.dom, this.canvas).attr(a ? a : {});
    },  
    /**
     * @method use
     * @param {String} id Id of the symbol element that you want to use
     * @param {Object} a Svg element attributes
     * @return {SvgUse}
     */
    use: function(id,a) {
        return new SvgUse("#"+id, this.dom, this.canvas).attr(a ? a : {});
    },
    
    /**
     * @method add
     * @param {SVGElement || SVGElement[] || Config object/array} svgEl
     * @return {SvgContainer}
     */
    add: function(svgEl) {  
        var dom = this.dom;
        var canvas = this.canvas;
        var addChild = function(o) {
            if (o instanceof SvgElement) {
                dom.appendChild(o.dom);
            } else {
                new SvgConfigParser(o,dom, canvas);
            }
        };
        
        if (isArray(svgEl)) {
            for (var i=0; i<svgEl.length; i++) {
                addChild(svgEl[i]);
            }
        } else {
            addChild(svgEl);
        }
        return this;
    },
    
    /**
     * @method clear
     */
    clear: function() {
        while (this.dom.firstChild) {
            this.dom.removeChild(this.dom.firstChild);
        }
    }
};
SvgContainer = SvgElement.extend(SvgContainer);